#if defined(CB_PRECOMP)
#include "sdk.h"
#endif
#ifndef CB_PRECOMP
	#include "configmanager.h"
	#include "manager.h"
#endif

#include "ThreadSearchView.h"
#include "ThreadSearchViewManagerMessagesNotebook.h"


ThreadSearchViewManagerMessagesNotebook::~ThreadSearchViewManagerMessagesNotebook() {
}


void ThreadSearchViewManagerMessagesNotebook::AddViewToManager() {
	if ( m_IsManaged == false )
	{
	
		wxBitmap bmp;
		wxString prefix = ConfigManager::GetDataFolder() + _T("/images/16x16/");
		bmp = cbLoadBitmap(prefix + _T("filefind.png"), wxBITMAP_TYPE_PNG);

	
		CodeBlocksLogEvent evtShow(cbEVT_ADD_LOG_WINDOW, m_pThreadSearchView, wxString(_T("Snippets search")), &bmp);
	

		CodeBlocksLogEvent evtSwitch(cbEVT_SWITCH_TO_LOG_WINDOW, m_pThreadSearchView);
	

	
		m_IsManaged = true;
		m_IsShown   = true;
	}
}

void ThreadSearchViewManagerMessagesNotebook::RemoveViewFromManager() {
	if ( m_IsManaged == true )
	{
	
		m_IsManaged = false;
		m_IsShown   = false;

	
	
		CodeBlocksLogEvent evt(cbEVT_REMOVE_LOG_WINDOW, m_pThreadSearchView);
	
	
	
	}
}


bool ThreadSearchViewManagerMessagesNotebook::ShowView(bool show) {
	if ( show == IsViewShown() )
		return false;


	if ( show == true )
	{
		if ( m_IsManaged == true )
		{
			CodeBlocksLogEvent evtShow(cbEVT_SHOW_LOG_MANAGER);
		
			CodeBlocksLogEvent evtSwitch(cbEVT_SWITCH_TO_LOG_WINDOW, m_pThreadSearchView);
		
			m_IsShown = true;
		}
		else
		{
			AddViewToManager();
		}
	}
	else
	{
		RemoveViewFromManager();
	}

	return true;
}


bool ThreadSearchViewManagerMessagesNotebook::IsViewShown() {
	return m_IsShown && IsWindowReallyShown((wxWindow*)m_pThreadSearchView);
}
